package edu.upenn.pcr.dao;

import android.content.Context;
import edu.upenn.pcr.model.db.PennCourseReviewDBMgr;
import edu.upenn.pcr.model.db.dao.DepartmentDAO;
import edu.upenn.pcr.model.db.entity.Department;
import edu.upenn.pcr.test.AndroidTestCaseBase;

public class DepartmentDAOTest extends AndroidTestCaseBase {

	private PennCourseReviewDBMgr dbMgr;
	
	@Override
	protected void setUp() throws Exception {
		super.setUp();
		Context context = this.getTestContext();
		dbMgr = PennCourseReviewDBMgr.getInstance(context);
	}
	
	public void testAddCount() {
		DepartmentDAO dao = dbMgr.getDepartmentDAO();
		dbMgr.beginTransaction();
		for (int i = 0; i < 10; i++) {
			Department d = new Department();
			d.setId(i+"");
			d.setName("CIS");
			d.setViewed(1);
			dao.add(d);
			int count = dao.count();
			assertEquals(i+1, count);
		}
		dbMgr.setTransactionSuccessful();
		dbMgr.endTransaction();
	}
}
